package com.example.mybaseapp.ui

import android.os.Bundle
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.mybaseapp.R
import com.example.mybaseapp.widget.circle_seekbar.ACircleSeekBar
import com.example.mybaseapp.widget.circle_seekbar.PointsData
import com.example.mybaseapp.widget.circle_seekbar.SelectListener

class CircleSeekBarActivity : AppCompatActivity() {
    private val mPointsData = mutableListOf(
        PointsData(100),PointsData(150),
        PointsData(200),PointsData(300),
        PointsData(400),PointsData(600),
        PointsData(800),PointsData(1200),
        PointsData(1600),PointsData(2400),
        PointsData(3200))

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_circle_seek_bar)
        initView()
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
    }

    private fun initView() {
        findViewById<ACircleSeekBar>(R.id.aACircleSeekBar).apply {
            addPoints(mPointsData)
            addSelectListener(object:SelectListener{
                override fun currentSelect(value: Any) {
                    if(value is PointsData){
                        Toast.makeText(this@CircleSeekBarActivity,value.value.toString(),Toast.LENGTH_SHORT).show()
                    }
                }

            })
        }
    }
}